package top.chengdongqing.mishop.product.vo

import top.chengdongqing.mishop.entities.Product
import java.io.Serializable
import java.math.BigDecimal

data class ProductVO(
    val id: Int,
    val name: String,
    val description: String?,
    val pictureUrl: String,
    val gallery: List<String>?,
    val price: BigDecimal,
    val originalPrice: BigDecimal?,
    val hasMultiplePrices: Boolean
) : Serializable {
    companion object {
        fun of(product: Product, gallery: List<String>?): ProductVO {
            return ProductVO(
                product.id,
                product.name,
                product.description,
                product.pictureUrl,
                gallery,
                product.price,
                product.originalPrice,
                product.hasMultiplePrices
            )
        }

        fun of(products: List<Product>): List<ProductVO> {
            return products.map { of(it, null) }
        }
    }
}
